import { remConfig } from '@/utils/rem/config.js'
import { useRemStore } from '@/store/remStore.js'
import { remInit, onResize } from '@/utils/rem/rem.js'

function setRemCfg(remType, config = remConfig) {
    const remStore = useRemStore()
    if (!remType || (remType === remStore.remType)) return;
    const remCfg = config[remType];
    remStore.$patch({
        pageWidth: remCfg.pageWidth,
        pageFontSize: remCfg.pageFontSize,
    });
    if (remStore.remType === 'Init') {
        remInit()
    } else {
        onResize()
    }
    remStore.remType = remType;

}

export default setRemCfg